/*!
 * Copyright (C) 2020 - All Rights Reserved by
 * @author : ZhaoYanbo
 * @email  : zyb920@hotmail.com
 * @created: 2020-10-31
 * @version: 1.0.0.0
 *
 */

#include "MainWidget.h"
#include "ui_MainWidget.h"
#include "AudioDecoder.h"
#include <QFileDialog>
#include <QtDebug>

MainWidget::MainWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::MainWidget)
{
    ui->setupUi(this);
    m_audio_ptr = new AudioDecoder(this);
}

MainWidget::~MainWidget()
{
    delete ui;
}

void MainWidget::on_addBtn_clicked()
{
    QStringList list =
    QFileDialog::getOpenFileNames(nullptr, "mp3", "D:/music", "MP3(*.mp3 *.wav);;All(*.*)");
    if(list.length() > 0)
        ui->listWidget->addItems(list);
}

void MainWidget::on_listWidget_itemDoubleClicked(QListWidgetItem *item)
{
    m_audio_ptr->play( item->text() );
}
